import { uploadType, regularRule,getAreaObj } from '@/utils/util'
export const detailConfig = {
	inline: false,
	labelPosition: 'right',
	column: [
		{
			type: 'DividerHtml',
			modelValue: '服务对象信息',
			labelPosition: 'top',
			span: 24,
		},
		{
			label: '服务对象姓名',
			prop: 'name',
			span: 8,
			maxlength: '20',
			showWordLimit: true,
			type: 'text',
			rules: [{ required: true, message: '请输入服务对象姓名' }],
		},
		{
			label: '服务对象身份证号',
			prop: 'idCard',
			span: 8,
			type: 'text',
			rules: [
				{ pattern: regularRule.idCard, message: '请输入正确的身份证号' },
				{ required: true, message: '请输入身份证号' },
			],
		},
		{
			label: '现居地址',
			prop: 'currentAddress',
			span: 8,
			maxlength: '140',
			showWordLimit: true,
			type: 'text',
			rules: [{ required: true, message: '请输入现居地址' }],
		},
		{
			label: '联系电话',
			prop: 'contactNo',
			span: 8,
			maxlength: '11',
			showWordLimit: true,
			type: 'text',
			rules: [
				{ pattern: regularRule.phone, message: '请输入正确的联系电话' },
				{ required: true, message: '请输入联系电话' },
			],
		},
		{
			label: '老人类别',
			prop: 'clientType',
			propName: 'clientTypeLabel',
			type: 'remoteSelect',
			code: 'ELDERLY_TYPE',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
			span: 8,
		},
		{
			label: '能力等级',
			prop: 'capacityLevel',
			propName: 'capacityLevelLabel',
			type: 'remoteSelect',
			code: 'ACCESS_LEVEL_COUNTRY',
			api: 'getDictItemList',
			filterKey: 'value',
			changeField: true,
			multiple: false,
			span: 8,
		},
		{
			type: 'DividerHtml',
			modelValue: '服务组织及人员信息',
			labelPosition: 'top',
			span: 24,
		},

		{
			label: '服务组织机构名称',
			prop: 'orgName',
			span: 8,
			maxlength: '50',
			showWordLimit: true,
			type: 'text',
			rules: [{ required: true, message: '请输入服务组织机构名称' }],
		},
		{
			label: '组织统一社会信用代码',
			prop: 'creditCode',
			maxlength: '18',
			showWordLimit: true,
			type: 'text',
			rules: [{ pattern: regularRule.code, message: '请输入正确的统一社会信用代码' }],
			span: 8,
		},
		{
			label: '服务人员证件号码',
			prop: 'staffIdCard',
			rules: [
				{ pattern: regularRule.idCard, message: '请输入正确的服务人员证件号码' },
				{ required: true, message: '请输入服务人员证件号码' },
			],
			span: 8,
		},
		{
			label: '服务人员',
			prop: 'serviceStaff',
			span: 8,
			maxlength: '50',
			showWordLimit: true,
			type: 'text',
			rules: [{ required: true, message: '请输入服务人员姓名' }],
		},
		{
			label: '联系电话',
			prop: 'staffContactNo',
			maxlength: '11',
			showWordLimit: true,
			type: 'text',
			span: 8,
			rules: [{ pattern: regularRule.phone, message: '请输入正确的联系电话' }],
		},
		{
			type: 'DividerHtml',
			modelValue: '工单信息',
			labelPosition: 'top',
			span: 24,
		},
		{
			label: '服务工单编号',
			prop: 'orderCode',
			span: 8,
			addDisplay: false,
			editDisplay: false,
		},
		{ label: '工单创建人', prop: 'creator', span: 8, addDisplay: false, editDisplay: false },
		{
			label: '服务项目',
			prop: 'serviceItem',
			propName: 'serviceItemLabel',
			span: 8,
			type: 'remoteSelect',
			code: 'SERVICE_ITEM_TYPE',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
			rules: [{ required: true, message: '请输入服务项目' }],
		},

		{
			label: '工单价格',
			prop: 'orderPrice',
			type: 'input',
			append: '元',
			rules: [{ pattern: regularRule.fixedTwoNum, message: '请输入正确的金额' }],
			span: 8,
		},
		{
			label: '补贴金额',
			prop: 'subsidyAmount',
			type: 'input',
			append: '元',
			rules: [{ pattern: regularRule.fixedTwoNum, message: '请输入正确的金额' }],
			span: 8,
		},
		{
			label: '机构减免金额',
			prop: 'orgDiscount',
			type: 'input',
			append: '元',
			rules: [{ pattern: regularRule.fixedTwoNum, message: '请输入正确的金额' }],
			span: 8,
		},
		{
			label: '实付金额',
			prop: 'payAmount',
			type: 'input',
			append: '元',
			rules: [{ pattern: regularRule.fixedTwoNum, message: '请输入正确的金额' }],
			span: 8,
		},
		{
			label: '工单所得时间币',
			prop: 'timecoinReward',
			type: 'input',
			append: '个',
			rules: [
				{ required: true, message: '请输入服务地址' },
				{ pattern: regularRule.number, message: '请输入正确的数量' },
			],
			span: 8,
		},
		{
			label: '服务地区',
			prop: 'areas_name',
			span: 8,
		},
		{
			label: '服务地址',
			prop: 'serviceAddress',
			changeField: true,
			maxlength: '140',
			showWordLimit: true,
			type: 'text',
			span: 8,
			rules: [{ required: true, message: '请输入服务地址' }],
		},
		{
			label: '接单时间',
			prop: 'orderTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
			rules: [{ required: true, message: '请选择接单时间' }],
		},
		{
			label: '开始服务时间',
			prop: 'startTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
			rules: [{ required: true, message: '请选择开始服务时间' }],
		},
		{
			label: '结束服务时间',
			prop: 'endTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
			rules: [{ required: true, message: '请选择结束服务时间' }],
		},
		{
			label: '服务时长',
			prop: 'serviceDuration',
			type: 'input',
			append: '秒',
			span: 8,
		},
		{
			label: '服务方式',
			prop: 'serviceMethod',
			propName: 'serviceMethodLabel',
			span: 8,
			code: 'SERVICE_METHOD',
			type: 'remoteSelect',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
			rules: [{ required: true, message: '请选择服务方式' }],
		},
		{
			label: '服务照片',
			prop: 'servicePhoto',
			type: 'upload',
			showFileList: false,
			limit: 1,
			multiple: false,
			custome: 'file',
			span: 8,
		},
		{
			label: '服务录音',
			prop: 'serviceRecord',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 1,
			multiple: false,
			span: 8,
		},
		{
			label: '服务视频',
			prop: 'serviceVideo',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 1,
			multiple: false,
			span: 8,
		},
		{
			label: '服务评价',
			prop: 'serviceEvaluation',
			span: 24,
			maxlength: '500',
			showWordLimit: true,
			type: 'textarea',
		},
		{
			label: '业务类型',
			prop: 'businessType',
			propName: 'businessTypeLabel',
			span: 8,
			code: 'BUSINESS_TYPE',
			type: 'remoteSelect',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
			rules: [{ required: true, message: '请选择业务类型' }],
		},
		{
			type: 'DividerHtml',
			modelValue: '回访信息',
			labelPosition: 'top',
			span: 24,
		},
		{
			label: '回访状态',
			prop: 'returnVisitStatus',
			propName: 'returnVisitStatusLabel',
			span: 8,
			code: 'RETURN_VISIT_STATUS',
			type: 'remoteSelect',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
		},

		{
			label: '回访人姓名',
			prop: 'returnVisitStaff',
			span: 8,
			maxlength: '20',
			showWordLimit: true,
			type: 'text',
		},
		{
			label: '回访结果',
			prop: 'returnVisitResult',
			propName: 'returnVisitResultLabel',
			code: 'RETURN_VISIT_RESULT',
			type: 'remoteSelect',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
			span: 8,
		},
		{
			label: '回访内容',
			prop: 'returnVisitNote',
			span: 24,
			maxlength: '500',
			showWordLimit: true,
			type: 'textarea',
		},
	],
}

export const baseConfig = {
	pageName: '社区居家服务工单',
	dictcodes: [
		'ELDERLY_TYPE',
		'ACCESS_LEVEL_COUNTRY',
		'SERVICE_ITEM_TYPE',
		'SERVICE_METHOD',
		'BUSINESS_TYPE',
		'RETURN_VISIT_STATUS',
		'RETURN_VISIT_RESULT',
	],
	rowKey: 'id',
	api: {
		index: 'view_dpCommunityServiceOrder_page',
	},
	auth: {
		index: 'view_dpCommunityServiceOrder_page',
	},
	menuBtn: [
		{
			icon: 'detail',
			label: '查看详情',
			type: 'primary',
			operate: 'detail',
			auth: 'view_dpCommunityServiceOrder_page',
			text: true,
			show: true,
		},
	],
	detailConfig,
	dialogConfig: {
		width: '90%',
	},
	tableConfig: {
		stripe: true,
		border: false,
		tableLayout: 'auto',
		columns: [
			{ label: '服务类别', prop: 'clientTypeLabel' },
			{ label: '证件号码', prop: 'idCard' },
			{ label: '服务对象', prop: 'name' },
			{ label: '联系方式', prop: 'contactNo' },
			{
				label: '服务地区',
				prop: 'areas_name',
			},
			{
				label: '服务人员',
				prop: 'serviceStaff',
			},
			{
				label: '服务项目',
				prop: 'serviceItemLabel',
			},
			{
				label: '服务组织',
				prop: 'orgName',
			},
			{
				label: '服务组织统一社会信用代码',
				prop: 'creditCode',
			},
			{
				label: '服务时间',
				prop: 'startTime',
			},
			{
				label: '操作',
				prop: 'menu',
				width: 200,
				fixed: 'right',
			},
		],
	},
	onLoadFormate: async (arr) => {
		console.log('到达2')
		const tableData = arr.map((item) => {
			const areas_name = getAreaObj(item, '')
			return {
				...item,
				areas_name,
			}
		})
		console.log(tableData, 'tableData')
		return Promise.resolve(Object.freeze(tableData))
	},
}
